package cn.zeal4j.configuration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.oauth2.provider.token.TokenEnhancer;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;
/**
 * @author Administrator
 * @file IntelliJ IDEA Spring-Security + Oauth2
 * @create 2020 09 29 22:36
 */
@Configuration
public class JwtTokenStoreConfiguration {

    @Bean
    public TokenStore getTokenStore(JwtAccessTokenConverter getJwtAccessTokenConverter) {
        return new JwtTokenStore(getJwtAccessTokenConverter);
    }

    @Bean
    public JwtAccessTokenConverter getJwtAccessTokenConverter() {
        JwtAccessTokenConverter jwtAccessTokenConverter = new JwtAccessTokenConverter();
        jwtAccessTokenConverter.setSigningKey("这不是盐【滑稽】 It's not salt [funny]");
        return jwtAccessTokenConverter;
    }

    @Bean
    public TokenEnhancer getJwtTokenEnhancer() {
        return new CustomJwtTokenEnhancer();
    }
}
